# from conf.config import cache
# from flask_mail import Message,Mail
# from conf.config import config
# from db.common import cli
# # from app import mail_manager
# import uuid
# mail_manager = Mail()
# FINDPW_PRE = "findPW"
# def create_mail_auth_Code(login_name,password,phone,mail):
#     random_Code = str(uuid.uuid1())[:6]
#     print(config['MAIL_USERNAME'])
#     print(mail)
#     message = Message('日报平台注册验证码',sender=config['MAIL_USERNAME'],recipients=[mail], body='您的验证码是：%s' %random_Code)
#     try:
#         mail_manager.send(message)
#     except Exception as err:
#
#         return err
#     cache.set(mail,random_Code)
#     print("......."+cache.get(mail))
#     return True
# def create_findPW_auth_Code(mail):
#     random_Code = str(uuid.uuid1())[:6]
#     message = Message('日报平台找回邮箱验证码', sender=config['MAIL_USERNAME'], recipients=[mail], body='您的验证码是：%s' % random_Code)
#     try:
#         mail_manager.send(message)
#     except Exception as err:
#         return False
#     cache.set(FINDPW_PRE+mail,random_Code)
#     return True
#
# def verify_auth_Code(mail,auth_Code):
#     try:
#         if auth_Code == cache.get(mail):
#             return True
#         else:
#             return False
#     except Exception as err:
#         return False
#
# def verify_findPW_auth_Code(mail,auth_Code):
#     try:
#         if auth_Code == cache.get(FINDPW_PRE+mail):
#             return True
#         else:
#             return False
#     except Exception as err:
#         return False
# def reset_PW(mail,PW):
#     sql = "update tb_user set password = '%s' where mail = '%s'"%tuple([PW,mail])
#     try:
#         cli.execute(sql)
#         return True
#     except Exception as err:
#         print(err)
#         return False
#
# def add_user(login_name,password,phone,mail):
#     sql1 = "select * from tb_user where login_name = '%s' or mail = '%s'"%tuple([login_name,mail])
#     res1 = cli.fetchall(sql1)
#     print(res1)
#     if len(res1)!= 0:
#         return False
#     sql = "insert into tb_user (login_name,password,phone,mail,is_admin,is_active) values ('%s', '%s', '%s', '%s', '%s', '%s')"%tuple([login_name,password,phone,mail,'no','no'])
#     print(sql)
#     try:
#         cli.execute(sql)
#         return True
#     except:
#         return False
#
#
# """
# 原本打算每个新注册的用户建立一个新表来记录与之相关的信息，星源讨论后说每条日报的信息量特别小，短时间内几乎不用考虑单表数据量过大的问题。
# 所以此方法注释掉，用统一的日报业务表记录所有信息
# """
# def add_user_report_table(login_name):
#     """
#     发送人表中的日报id；时间：年-月-日-时-分-秒（以收到用户请求的时刻作为创建时间）；发送人；接收人（多人，以loginname或用户id标识）；title日报名称；
#     部门（保留）；项目组；今日完成；困难或待解决问题；明天的工作计划；
#     :param login_name:
#     :return:
#     """
#     lst = [ "log_id", "date_time", "author", "receiver", "title",
#            "department","project", "today_work",
#            "remain_todo", "tomorrow_work"]
#     lst2 = [login_name+'_logs'].__add__(lst)
#     sql = "CREATE TABLE {0[0]} (" \
#           "{0[1]} int(11) NOT NULL AUTO_INCREMENT,  " \
#           "{0[2]} date NOT NULL, " \
#           "{0[3]} varchar(255) NOT NULL, " \
#           "{0[4]}  varchar(255) NOT NULL," \
#           "{0[5]} varchar(255) NOT NULL," \
#           "{0[6]} varchar(255) NOT NULL," \
#           "{0[7]} varchar(255) NOT NULL," \
#           "{0[8]} varchar(255) NOT NULL," \
#           "{0[9]} varchar(255) NOT NULL," \
#           "{0[10]} varchar(255) NOT NULL," \
#           "PRIMARY KEY ({0[1]}))" \
#           "ENGINE=InnoDB DEFAULT CHARSET=utf8;".format(lst2)
#     print(sql)
#     cli.execute(sql)
#
#
# def find_user_data(mail):
#     sql = "select login_name,phone from tb_user where mail = '%s'"%tuple([mail])
#     cli.fetchall(sql)[0]
#     return cli.fetchall(sql)[0]
#
#
#
#
